import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/',
  name: 'index',
  component: () => import('../views/index.vue'),
  redirect: '/main',
  children: [{
      path: '/main',
      meta: {
        title: '首页'
      },
      component: () => import('../views/main.vue')
    },
    {
      path: '/resources',
      meta: {
        title: '下载·课程'
      },
      component: () => import('../views/resources/index.vue')
    },
    {
      path: '/editor',
      meta: {
        title: '发布文章'
      },
      component: () => import('../views/creation/editor.vue')
    },
    {
      path: '/community',
      meta: {
        title: '社区'
      },
      component: () => import('../views/community/index.vue')
    },
    {
      path: '/certificate',
      meta: {
      title: '证书·认证'
      },
      component: () => import('../views/certificate/index.vue')
    },
    {
      path: '/creation',
      meta: {
      title: '首页-创作中心'
      },
      component: () => import('../views/creation/index.vue')
    },
    
    {
      path: '/blog/:id',
      meta: {
        title: '博客详情'
      },
      component: () => import('../views/blog/index.vue')
    },
    {
        path: '/user-center',
        component: () => import('../views/userCenter/index.vue'),
        redirect: '/personal-data',
        children: [{
            path: '/personal-data',
            meta: {
              title: '个人资料'
            },
            component: () => import('../views/userCenter/personal-data.vue')
          },
          {
            path: '/account-settings',
            meta: {
              title: '账号设置'
            },
            component: () => import('../views/userCenter/account-settings.vue')
          },
          {
            path: '/browsing-history',
            meta: {
              title: '浏览历史'
            },
            component: () => import('../views/userCenter/browsing-history.vue')
          }
  
        ]
      },
       {
      path: '/personal',
      meta: {
        title: '个人主页'
      },
      component: () => import('../views/personalPage/index.vue')
    }
    // {
    //   path: '/resources',
    //   meta: {
    //     title: '下载·课程'
    //   },
    //   component: () => import('../views/resources/index.vue')
    // },
    // {
    //   path: '/download-index',
    //   meta: {
    //     title: '下载主页'
    //   },
    //   component: () => import('../views/resources/download-index.vue')
    // },
    // {
    //   path: '/course-index',
    //   meta: {
    //     title: '课程主页'
    //   },
    //   component: () => import('../views/resources/course-index.vue')
    // },
    // {
    //   path: '/topic-index',
    //   meta: {
    //     title: '专栏主页'
    //   },
    //   component: () => import('../views/resources/topic-index.vue')
    // },
    // {
    //   path: '/downloadResources/:id',
    //   meta: {
    //     title: '下载资源'
    //   },
    //   component: () => import('../views/resources/downloadResources.vue')
    // },

    // {
    //   path: '/download-resources',
    //   meta: {
    //     title: '上传资源'
    //   },
    //   component: () => import('../views/resources/upload-resources.vue')
    // },
    // {
    //   path: '/personal',
    //   meta: {
    //     title: '个人主页'
    //   },
    //   component: () => import('../views/personalPage/index.vue')
    // },
    // 

  ]
}]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.afterEach(to => {
  document.title = to.meta.title
})

export default router